<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
<head>
    <base href="<%=basePath%><%!private Object basePath;%>">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
    <title>“墨趣”网上书城</title>
    <link rel="stylesheet" type="text/css" href="css/style.css" />
</head>
<body>
<div id="wrap">

       <div class="header">
       		<div class="logo"><a href="index.jsp"><img src="images/logo.gif" alt="" title="" border="0" /></a></div>
        <div id="menu">
            <ul>
            <li><a href="index.jsp">首页</a></li>
            <li class="selected"><a href="about.jsp">关于我们</a></li>
            <li><a href="category.jsp">所有图书</a></li>
            <li><a href="specials.jsp">特别推荐</a></li>
            <li><a href="details.jsp">图书详情</a></li>
            <li><a href="/orders/getlistByuid.action">我的订单</a></li>
            <c:if test="${empty loger}">
                <li><a href="myaccount.jsp">登录</a></li>
                <li><a href="register.jsp">注册</a></li>
            </c:if>
            <c:if test="${not empty loger}">
                <li><a href="/user/doexit.action">退出</a></li>
            </c:if>
            </ul>
        </div>     
            
            
       </div> 
       
       
       <div class="center_content">
       	<div class="left_content">
            <div class="title"><span class="title_icon"><img src="images/bullet1.gif" alt="" title="" /></span>购物车</div>
        
        	<div class="feat_prod_box_details">
            
            <table class="cart_table" >
            	<tr class="cart_title">
                	<td></td>
                	<td>书名</td>
                    <td>单价</td>
                    <td>数量</td>
                    <td>总计</td>
                    <td>操作</td>
                </tr>
                <tbody id="nbody">
                </tbody>
                <c:forEach items="${carlist}" var="car">
                    <tr>
                    <td><input type="checkbox" value="${car.id}" name="single" onclick="sum()"></td>
                    <td>${car.bname}</td>
                    <td name="price">${car.price}</td>
                    <td name="num">${car.num}</td>
                    <td name="sumprice" >${car.num*car.price}</td>
                    <td><a href="javascript:void(0)" onclick="removecar(${car.id})">移出购物车</a></td>
                    </tr>
                </c:forEach>

                <tr>
                <td colspan="4" class="cart_total"><span class="red" >总价格:</span></td>
                <td id="sum"> ￥356</td>
                </tr>  

            
            </table>
            <a href="#" class="continue">&lt; 继续</a>
            <a href="#" class="checkout">结账 &gt;</a>

            </div>	

            
        <div class="clear"></div>
        </div><!--end of left content-->

           <div class="right_content">

               <div class="languages_box">
                   <span class="red">语言:</span>
                   <a href="#"><img src="images/gb.gif" alt="" title="" border="0" /></a>
                   <a href="#"><img src="images/fr.gif" alt="" title="" border="0" /></a>
                   <a href="#"><img src="images/de.gif" alt="" title="" border="0" /></a>
               </div>
               <div class="currency">
                   <span class="red">货币: </span>
                   <a href="#">GBP</a>
                   <a href="#">EUR</a>
                   <a href="#"><strong>USD</strong></a>
               </div>


               <div class="cart">
                   <div class="title"><span class="title_icon"><img src="images/cart.gif" alt="" title="" /></span>我的购物车</div>
                   <div class="home_cart_content">
                       3 件物品 | <span class="red">总计: 100￥</span>
                   </div>
                   <a href="/shopcar/getShopcarByUid.action" class="view_cart">查看购物车</a>
               </div>

               <div class="title"><span class="title_icon"><img src="images/bullet3.gif" alt="" title="" /></span>关于我们的商店</div>
               <div class="about">
                   <p>
                       <img src="images/about.gif" alt="" title="" class="right" />
                       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;洛雷姆·伊普索姆·多尔坐在阿米特的座位上，他是一位非常优秀的运动员，他是一位非常出色的速度运动员，他在拉伯和多洛尔·马格纳·阿利夸尔的比赛中发挥了重要作用。但我是小维尼安人，诺查德人。洛雷姆·伊普索姆·多尔坐在阿米特的座位上，他是一位非常优秀的运动员，他是一位非常出色的速度运动员，他在拉伯和多洛尔·马格纳·阿利夸尔的比赛中发挥了重要作用。但我是小维尼安人，诺查德人。
                   </p>

               </div>

               <div class="right_box">

                   <div class="title"><span class="title_icon"><img src="images/bullet4.gif" alt="" title="" /></span>促销</div>
                   <div class="new_prod_box">
                       <a href="details.jsp">产品名称</a>
                       <div class="new_prod_bg">
                           <span class="new_icon"><img src="images/promo_icon.gif" alt="" title="" /></span>
                           <a href="details.jsp"><img src="images/thumb1.gif" alt="" title="" class="thumb" border="0" /></a>
                       </div>
                   </div>

                   <div class="new_prod_box">
                       <a href="details.jsp">产品名称</a>
                       <div class="new_prod_bg">
                           <span class="new_icon"><img src="images/promo_icon.gif" alt="" title="" /></span>
                           <a href="details.jsp"><img src="images/thumb2.gif" alt="" title="" class="thumb" border="0" /></a>
                       </div>
                   </div>

                   <div class="new_prod_box">
                       <a href="details.jsp">产品名称</a>
                       <div class="new_prod_bg">
                           <span class="new_icon"><img src="images/promo_icon.gif" alt="" title="" /></span>
                           <a href="details.jsp"><img src="images/thumb3.gif" alt="" title="" class="thumb" border="0" /></a>
                       </div>
                   </div>

               </div>

               <div class="right_box">

                   <div class="title"><span class="title_icon"><img src="images/bullet5.gif" alt="" title="" /></span>分类</div>

                   <ul class="list">
                       <li><a href="#">饰品</a></li>
                       <li><a href="#">书籍礼品</a></li>
                       <li><a href="#">特别推荐</a></li>
                       <li><a href="#">节日礼品</a></li>
                       <li><a href="#">饰品</a></li>
                       <li><a href="#">书籍礼品</a></li>
                       <li><a href="#">特别推荐</a></li>
                       <li><a href="#">节日礼品</a></li>
                       <li><a href="#">饰品</a></li>
                       <li><a href="#">书籍礼品</a></li>
                       <li><a href="#">特别推荐</a></li>
                   </ul>

                   <div class="title"><span class="title_icon"><img src="images/bullet6.gif" alt="" title="" /></span>伙伴</div>

                   <ul class="list">
                       <li><a href="#">饰品</a></li>
                       <li><a href="#">书籍礼品</a></li>
                       <li><a href="#">特别推荐</a></li>
                       <li><a href="#">节日礼品</a></li>
                       <li><a href="#">饰品</a></li>
                       <li><a href="#">书籍礼品</a></li>
                       <li><a href="#">特别推荐</a></li>
                       <li><a href="#">节日礼品</a></li>
                   </ul>
               </div>
           </div><!--end of right content-->


           <div class="clear"></div>
       </div><!--end of center content-->


    <div class="footer">
        <div class="left_footer"><img src="images/footer_logo.gif" alt="" title="" /><br /> <a href="http://www.cssmoban.com/" title="free templates">cssmoban</a></div>
        <div class="right_footer">
            <%--<a href="#">home</a>
            <a href="#">about us</a>
            <a href="#">services</a>
            <a href="#">privacy policy</a>
            <a href="#">contact us</a>
           --%>
        </div>
    </div>
</div>
<script src="back/assets/js/jquery-1.12.4.js"></script>
<script>
    $(function(){
        console.log("asdf");
        // $.getJSON("shopcar/getShopcarByUid.action","",function(res){
        //     for(var i=0;i<res.length;i++){
        //     var newtr=$("<tr></tr>");
        //     newtr.append("<td><a href=\"details.jsp\"><img src=\"images/cart_thumb.gif\" alt=\"\" title=\"\" border=\"0\" class=\"cart_thumb\" /></a></td>");
        //     newtr.append("<td>"+res[i].bname+"</td>");
        //     newtr.append(" <td>￥"+res[i].price+"</td>");
        //     newtr.append("<td>"+res[i].num+"</td>");
        //     newtr.append("<td>"+res[i].price * res[i].num+" </td>");
        //     newtr.append("<td><a href='javascript:void(0)'>移出购物车</a> </td>");
        //     $("#nbody").append(newtr);
        //     }
        // });
    })

    //移出购物车
    function removecar(id){
        if(confirm("你确定要移出购物车吗？")){
            $.getJSON("shopcar/delShopcar.action","id="+id,function(res){
                alert("操作成功");
                location="/shopcar/getShopcarByUid.action";
            })
        }
    }

    //计算要结算的商品的总价
    function sum(){
        var arr=document.getElementsByName("single");
        var sum=0;
        for(var i in arr)
        {
            //alert(arr[i].checked);
            if(arr[i].checked)
            {
                //把javascript转成jquery
                var xx=$(arr[i]);
                var price=xx.parents("tr").find("td[name=price]").val();
                console.log(price);
                //alert(price);
                var num=xx.parents("tr").find("td[name=num] ").val();
                console.log(num);
              //  alert(num);
                sum=sum+price;
                console.log(sum);
            }
        }
        $("#sum").html("131.4");
    }
</script>
</body>
</html>